package com.digitalchina.lxnsy.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.ShareFarmListVO;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.facebook.drawee.view.SimpleDraweeView;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2018/8/10 11:10
 * 修改备注：
 * ================================================
 */

public class ShareFarmListHolder extends BaseViewHolder<ShareFarmListVO> {

    private SimpleDraweeView ivPicture;
    private TextView tvType;
    private TextView tvPrice;
    private TextView tvTitle;
    private TextView tvSales;
    private TextView tvTel;


    public ShareFarmListHolder(ViewGroup parent) {
        super(parent, R.layout.item_share_farm_list);
        ivPicture = $(R.id.sdv_images);
        tvTitle = $(R.id.tv_title);
        tvType = $(R.id.tv_type);
        tvPrice = $(R.id.tv_price);
        tvSales = $(R.id.tv_sales);
        tvTel = $(R.id.tv_tel);
    }

    @Override
    public void setData(ShareFarmListVO data) {
        super.setData(data);

        String url = "";
        if (data.imgPath != null)
            url = data.imgPath;
        FrescoUtil.showImageSmall(url, ivPicture);

        tvTitle.setText(data.getName() + "");


                if(data.getShareType().size()==2){
                  tvPrice.setText(data.getSharePrice() + " 元/"+data.getUnit().name);
                    //TODO 销量
                    tvType.setText("保证金："+data.getEnsureMoney());

                }else{
                    if("共享".equals(data.getShareType().get(0).name)){
                        tvPrice.setText(data.getSharePrice() + " 元/"+data.getUnit().name);
                        //TODO 销量
                        tvType.setText("保证金："+data.getEnsureMoney());

                    }else{
                        tvPrice.setText(data.getSellPrice() + " 元");
                        tvType.setVisibility(View.GONE);


                    }



                }


        tvSales.setText(data.getPickUpAddress());
        tvTel.setText(data.getContactNumber());
    }

}
